package edu.byu.intex2.data.bo;

import edu.byu.intex2.data.DataException;
import edu.byu.intex2.data.dao.*;
/**
 * @author Jason Whiting
 */
public class Dealership extends BusinessObject
{

    private String address;
    private String phone;
    private String serviceFacilityId;
    private ServiceFacility serviceFacility;

    /**
     * Creates a new instance of BusinessObject
     * @param id
     */
    public Dealership(String id)
    {
        super(id);
    }//constructor

    //Quick Access Method
    public void save() throws DataException
    {
        try
        {
            DealershipDAO.getInstance().save(this);
        } catch (DataException e)
        {
            e.printStackTrace();
        }
    }

    /**
     * @return the address
     */
    public String getAddress()
    {
        return address;
    }

    /**
     * @param address the address to set
     */
    public void setAddress(String address)
    {
        this.address = address;
        this.setDirty();
    }

    /**
     * @return the phone
     */
    public String getPhone()
    {
        return phone;
    }

    /**
     * @param phone the phone to set
     */
    public void setPhone(String phone)
    {
        this.phone = phone;
        this.setDirty();
    }

    /**
     * @return the serviceFacilityId
     */
    public String getServiceFacilityId()
    {
        return serviceFacilityId;
    }

    /**
     * @param serviceFacilityId the serviceFacilityId to set
     */
    public void setServiceFacilityId(String serviceFacilityId)
    {
        this.serviceFacilityId = serviceFacilityId;
        this.setDirty();
    }

    /**
     * @return the serviceFacility from the DAO
     */
    public ServiceFacility getServiceFacility()
    {
        if (serviceFacility == null)
        {
            try
            {
                serviceFacility = ServiceFacilityDAO.getInstance().read(serviceFacilityId);
            } catch (Exception e)
            {
                e.printStackTrace();
            }
        }
        return serviceFacility;
    }

    /**
     * @param serviceFacility the serviceFacility to set
     */
    public void setServiceFacility(ServiceFacility serviceFacility)
    {
        this.serviceFacility = serviceFacility;
    }
}
